-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error Handling for HTTP Status Codes #67
Error Handling for HTTP Status Codes #67
Conversation
…than a success and to catch and handle that result, either by resubmitting the request after a delay or exiting with a relevant message. Handling codes were added to search.py in order to identify how each HTTP status code should be handled. The handling of these codes occur within __main__.py.
…te the submitted requests and modified __main__.py to catch assertion errors for both search methods, and to retry if the handling code indicates that should happen.
Sorry for the delayed response BTW, I was busy with some school work |
… if the request is None.
…than a success and to catch and handle that result, either by resubmitting the request after a delay or exiting with a relevant message. Handling codes were added to search.py in order to identify how each HTTP status code should be handled. The handling of these codes occur within __main__.py.
…te the submitted requests and modified __main__.py to catch assertion errors for both search methods, and to retry if the handling code indicates that should happen.
… if the request is None.
…starcli into additional_error_handling Modified the search and search_github_trending methods to return None if request is None.
Do you think having a dict of status codes, instead of a bunch of |
It's totally fine to keep it as is if you don't want to change it though, because |
You're right about using a dict rather than creating a handful of variables, and it'll be able to scale easier. I'm not sure why I didn't think of it at the time. I'll get the changes made here in a bit. |
…as modified to use a dict containing the different handling codes and the messages that should be printed if the code is encountered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 looks great!
Added error handling based on HTTP status codes. The status codes identified after submitting the GET request for the URL will produce a handling code which informs the cli method how it should proceed, either exiting the application or retrying the request. A message will be displayed to inform the user of the nature of the error or that a retry will occur in a given amount of time.
Context
This will prevent errors originating from unsuccessful requests from reaching the user.
Description
Added a request validation method to search.py which both search and search_github_trending call when submitting a GET request. This will catch a connection error and raise an assertion error in the case of an HTTP status code indicating something other than a success. Added a search_error method which processes the assertion error and returns the appropriate handling code for the assertion error.
A while loop has been added to the cli method which contains the calls to search and search_github_trending in order to allow requests to be resubmitted (if appropriate) and messages are printed for the user to indicate the nature of the issue, based on the handling code.